package com.innoking.docsys.doc.controller;

import com.innoking.docsys.borrow.module.MyBorrowVo;
import com.innoking.docsys.doc.service.MyBorrowService;
import com.innoking.docsys.utils.JsonToOtherUtil;
import com.innoking.docsys.utils.OtherPojo;
import com.innoking.docsys.utils.ResultObjVO;
import com.innoking.docsys.utils.ResultUtil;
import com.waypolice.common.constant.BorrowConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 描述:
 *
 * @author zyp
 * @description 我的借阅controller
 * @create 2019-09-10 11:35
 */
@RestController
@RequestMapping("/myBorrow")
public class MyBorrowController {

    Logger logger= LoggerFactory.getLogger(MyBorrowController.class);

    @Autowired
    private MyBorrowService myBorrowService;

    /**
     * @author:zyp
     * @description 获取我借阅的列表
     * @date: 2019/9/10 13:53
     * @return
     */
    @PostMapping(value = "/getMyBorrow")
    public ResultObjVO getMyBorrow(@RequestBody String data){
        OtherPojo ob = JsonToOtherUtil.rtOtherPojo(data,new MyBorrowVo());
        MyBorrowVo myBorrowVo = (MyBorrowVo)ob.getObj();
        ResultObjVO resultObjVO = myBorrowService.getMyBorrow(myBorrowVo);
        return resultObjVO;
    }

    /**
     * @author:zyp
     * @description 归还线上借阅的授权文件
     * @date: 2019/9/10 15:19
     * @return
     */
    @PostMapping(value = "/returnAccreditArch")
    public ResultObjVO returnAccreditArch(@RequestBody String data){
        OtherPojo ob = JsonToOtherUtil.rtOtherPojo(data,new MyBorrowVo());
        MyBorrowVo myBorrowVo = (MyBorrowVo)ob.getObj();
        ResultObjVO resultObjVO = myBorrowService.returnAccreditArch(myBorrowVo);
        return resultObjVO;
    }

    /**
     * @author:zyp
     * @description 查看线上借阅的授权文件
     * @date: 2019/9/10 15:52
     * @return
     */
    @RequestMapping(value = "/watchOriginalImg")
    @ResponseBody
    public byte[] watchOriginalImg(@RequestBody String data){
        OtherPojo ob = JsonToOtherUtil.rtOtherPojo(data,new MyBorrowVo());
        MyBorrowVo myBorrowVo = (MyBorrowVo)ob.getObj();
        byte[] bytedownloadFile = myBorrowService.watchOriginalImg(myBorrowVo);
        return bytedownloadFile;

    }

}